# coding=utf-8
import numpy as np

from lib.Core.common import area
from lib.Core.AStar import AStar
from UI.Map.Block import Block


def main():
    width = 20
    height = 20
    # 地图数组
    map_arr = []
    for x in range(width):
        arr = []
        for y in range(height):
            arr.append(Block(1))
        map_arr.append(arr)
    # 人物坐标
    pos_char = 7, 7
    # 人物位置不可移动
    map_arr[pos_char[0]][pos_char[1]].can_move = True
    # 人物移动范围 10
    map_size = width, height
    move_area = area(map_size, pos_char, 10)
    for pos_block in move_area:
        map_arr[pos_block[0]][pos_block[1]].can_move = True
    # 敌人控制范围内 不可寻路（阻挡）
    # char_area = area(map_size, pos_char, 4)
    # for pos_block in char_area:
    #     map_arr[pos_block[0]][pos_block[1]].can_move = False
    # y: 8  x : 0-19 不可移动
    for x in range(19):
        map_arr[8][x].can_move = False
    # A 寻路
    a_star = AStar(map_arr, pos_char, [10, 5])
    a_star.find_path()
    path = np.array(a_star.get_path())
    print(path)


if __name__ == '__main__':
    main()
